/*
 * Copyright (C) 2010-2011 Comcast Cable.  All Rights Reserved.
 */
package com.hercules.android.receiver.model.commands;

/**
 * <p>This is a subclass of XRECommand that represents a REDIRECT XRE command. It defines some properties specific to
 * this command. This command is used for redirecting connection to another location. It is a simple JavaBean (POJO)
 * that provides getters and setters for all private attributes and performs no argument validation in the setters.</p>
 *
 * <p><strong>Thread safety:</strong> This class is mutable and not thread safe.</p>
 *
 * @author saarixx, jmn
 * @version 1.0
 */
public class XRERedirectCommand extends XRECommand {

    /**
     * <p>The command name associated with this class.</p>
     *
     * <p>Immutable string constant.</p>
     *
     * <p>Is used in getCommand().</p>
     */
    public static final String COMMAND_NAME = "REDIRECT";

    /**
     * <p>The XRE URL that describes the destination of the redirection.</p>
     *
     * <p>The receiver will establish an XRE connection to this URL.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private String url;

    /**
     * <p>The value that indicates whether the receiver should maintain the existing XRE application session, including
     * the view DOM and resource table.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private boolean preserveSession;

    /**
     * <p>The reason for redirection.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private String reason;

    /**
     * <p>The code of the redirect reason.</p>
     *
     * <p>Can be any value.</p>
     *
     * <p>Has getter and setter.</p>
     */
    private int statusCode;

    /**
     * <p>Creates new instance of {@link XRERedirectCommand} class.</p>
     */
    public XRERedirectCommand() {
        // empty constructor
    }

    /**
     * <p>Retrieves the name of this command.</p>
     *
     * @return the name of this command
     */
    public String getCommand() {
        return COMMAND_NAME;
    }

    /**
     * <p>Retrieves the XRE URL that describes the destination of the redirection.</p>
     *
     * @return the XRE URL that describes the destination of the redirection
     */
    public String getUrl() {
        return url;
    }

    /**
     * <p>Sets the XRE URL that describes the destination of the redirection.</p>
     *
     * @param url the XRE URL that describes the destination of the redirection
     */
    public void setUrl(String url) {
        this.url = url;
    }

    /**
     * <p>Retrieves the value that indicates whether the receiver should maintain the existing XRE application session,
     * including the view DOM and resource table.</p>
     *
     * @return the value that indicates whether the receiver should maintain the existing XRE application session,
     *         including the view DOM and resource table
     */
    public boolean isPreserveSession() {
        return preserveSession;
    }

    /**
     * <p>Sets the value that indicates whether the receiver should maintain the existing XRE application session,
     * including the view DOM and resource table.</p>
     *
     * @param preserveSession the value that indicates whether the receiver should maintain the existing XRE application
     *                        session, including the view DOM and resource table
     */
    public void setPreserveSession(boolean preserveSession) {
        this.preserveSession = preserveSession;
    }

    /**
     * <p>Retrieves the reason for redirection.</p>
     *
     * @return the reason for redirection
     */
    public String getReason() {
        return reason;
    }

    /**
     * <p>Sets the reason for redirection.</p>
     *
     * @param reason the reason for redirection
     */
    public void setReason(String reason) {
        this.reason = reason;
    }

    /**
     * <p>Retrieves the code of the redirect reason.</p>
     *
     * @return the code of the redirect reason
     */
    public int getStatusCode() {
        return statusCode;
    }

    /**
     * <p>Sets the code of the redirect reason.</p>
     *
     * @param statusCode the code of the redirect reason
     */
    public void setStatusCode(int statusCode) {
        this.statusCode = statusCode;
    }
}

